﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OlegGutsalo;

namespace GutsaloUnitTest
{
    [TestClass]
    public class CalculatorUnitTest
    {
        [TestMethod]
        public void NoValues()
        {
            int expected = 0;
            int result = StringCalculator.Add("");
            Assert.IsTrue(expected==result,"No narametrs does not allowed.");
        }

        [TestMethod]
        public void OneValue()
        {
            int expected = 1;
            int result = StringCalculator.Add("1");
            Assert.IsTrue(expected == result, "Parametrs does not mutch.");
        }

        [TestMethod]
        public void TwoValues()
        {
            int expected = 3;
            int result = StringCalculator.Add("1,2");
            Assert.IsTrue(expected == result, "Sum of parametrs does not match with expected.");
        }

        [TestMethod]
        public void MultipleValues()
        {
            int expected = 15;
            int result = StringCalculator.Add("1,2,3,4,5");
            Assert.IsTrue(expected == result, "Sum of parametrs does not match with expected.");
        }

        [TestMethod]
        public void Delimiter()
        {
            int result = StringCalculator.Add("//&\n1&2&3\n4");
            Assert.AreEqual(10, result, "Wrong string declaration.");
        }

        [TestMethod]
        [ExpectedException(typeof(System.ArgumentException), 
            "Negative numbers does not allowed.")]
        public void NegativeNumbers()
        {
            int result = StringCalculator.Add("1,2,3,-5,-1,1,-2\n-7");
        }

        [TestMethod]
        public void BigNumbers()
        {
            Assert.AreEqual(940, StringCalculator.Add("10,1500,30,900"),
                "Wrong answer returned.");
        }

        [TestMethod]
        public void LargeDelimiter()
        {
            int result = StringCalculator.Add("//[&&&]\n1&&&2&&&3\n4");
            Assert.AreEqual(10, result, "Wrong string declaration.");
        }

        [TestMethod]
        public void MultipleDelimiters()
        {
            int result = StringCalculator.Add("//[&&&][..][!]\n1&&&2!3..4");
            Assert.AreEqual(10, result, "Wrong string declaration.");
        }

    }
}
